home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / VU External Tool libs / OnTargetOperations.Lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  7.4 KB  |  211 lines  |  [TEXT/MPS ]

  1. # ****************************************************************************
  2. #
  3. #    File Name:    OnTargetOperations.Lib
  4. #
  5. #    Contains:    Tasks which extend the basic functionality of the OnTarget.lib.
  6. #
  7. #    Written by:    KTA
  8. #
  9. #    Copyright:    © 1993-1997 by Apple Computer, Inc., all rights reserved.
  10. #
  11. # ****************************************************************************
  12. #            C h a n g e        H i s t o r y (most recent first):
  13. # ****************************************************************************
  14. #
  15. #        Vers      Date        Author        Description
  16. #        ----    --------    ------    ---------------------------------------------
  17. #        1.2.1    02/12/97    JAS        Added 'vers' resources to library.
  18. #                                    These should always match tool version when tool is revved.
  19. #         <7>     2/28/95    ML        marked
  20. #         <6>     2/16/95    KTA        _OnTarget() - Replaced with standard new version of standard
  21. #                                    template which fixes some problems.
  22. #         <5>     1/19/95    KTA        Changed the name of ExceptionHandler() to ExceptionDispatcher().
  23. #         <4>     1/13/95    KTA        _Ontarget() - Added support for calling tasks as well as
  24. #                                    services.
  25. #         <3>    12/12/94    KTA        _OnTarget()- changed match[target] to match[mouse].
  26. #         <2>    12/12/94    KTA        Added _OnTarget().
  27. #         <1>     3/28/94    KTA        Created - first checked in.
  28. #
  29. # ****************************************************************************
  30. #
  31.  
  32. ########################################################################
  33. #                            External libraries 
  34. #=======================================================================
  35. Libraries "OnTarget.Lib", "ExceptionHandling.Lib";
  36.  
  37. #########################################################################
  38. #            _OnTarget(pServiceOrTask, pParamList, pOnTarget, pIsRetry)
  39. #========================================================================
  40. # Author:        KTA 
  41. # Description:    Does the exception handling for the OnTarget.  All high level tasks
  42. #                should call this routine for OnTarget tool services.  
  43. #                Handles initialization of tool automatically.
  44. # Parameters:    pServiceOrTask - Name of the Service
  45. #                pParamList - List of parameters
  46. #                pOnTarget - Flag to indicate whether the service should be performed 
  47. #                            the host or the target.  1 = target/0 = host.
  48. # Returns:        What ever the OnTarget returns - list of three elements
  49. #                            { errCode, Data, [error message]}
  50. # Examples:        _OnTarget('Initialize', {1});
  51. # Assumptions:    None 
  52. #========================================================================
  53. # History:
  54. # KTA    12/12/94    Created
  55. # KTA    1/13/95        Added support for calling tasks as well as services.
  56. # KTA    2/16/95        coerce pOnTarget to be either true or false, Temporarily
  57. #                    turn commandexceptions off, check scripterror, reset 
  58. #                    commandexceptions, and if necessary throw scripterror 
  59. #########################################################################
  60. TASK _OnTarget(pServiceOrTask, pParamList := {}, pOnTarget := true, pIsRetry := 0)
  61. begin
  62.     Try
  63.     begin
  64.         returnVal := undefined;
  65.         ParamType := TypeOf(pServiceOrTask);
  66.         
  67.         if (ParamType = 'string') # Service Call
  68.         begin
  69.             if (pOnTarget)
  70.                 pOnTarget := true;
  71.             else
  72.                 pOnTarget := false;
  73.             if not(global gOnTargetInitFlag = pOnTarget)
  74.             begin
  75.                 try
  76.                 begin
  77.                     temp := CommandExceptions(0);
  78.                     OnTargetInit :=  OnTarget("Initialize", pOnTarget );         # initialize OnTarget
  79.                     InitError := Scripterror();
  80.                     CommandExceptions(temp);
  81.                     if (OnTargetInit[1] <> 0)        # If error
  82.                     begin
  83.                         println "OnTarget error ( ", OnTargetInit[1], ", ",  OnTargetInit[3] , " )";
  84.                         gOnTargetInitFlag := undefined;
  85.                         if (CommandExceptions())
  86.                             throw InitError;
  87.                         return(OnTargetInit);
  88.                     end;
  89.                     else
  90.                         gOnTargetInitFlag := pOnTarget;
  91.                 end;
  92.                 catch theErr
  93.                 begin
  94.                     ExceptionDispatcher(theErr);
  95.                     return(OnTargetInit);
  96.                 end;
  97.             end;
  98.  
  99.             try
  100.             begin
  101.                 NumParams := Card(pParamList);
  102.                 switch NumParams
  103.                 begin
  104.                     case 0:                    # 0 parameters
  105.                         returnVal := OnTarget(pServiceOrTask); 
  106.                     case 1:                    # 1 parameter
  107.                         returnVal := OnTarget(pServiceOrTask, pParamList[1]); 
  108.                     case 2:                    # 2 parameters
  109.                         returnVal := OnTarget(pServiceOrTask, pParamList[1], pParamList[2]); 
  110.                     case 3:                    # 3 parameters
  111.                         returnVal := OnTarget(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3]); 
  112.                     case 4:                    # 4 parameters
  113.                         returnVal := OnTarget(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4]); 
  114.                     case 5:                    # 5 parameters
  115.                         returnVal := OnTarget(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5]); 
  116.                     case 6:                    # 6 parameters
  117.                         returnVal := OnTarget(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5], pParamList[6]); 
  118.                     default:                # error
  119.                         println "Error - unsupported number of parameters - {NumParams}";
  120.                 end;
  121.         
  122.                 if (returnVal[1] <> 0)        # If error
  123.                 begin
  124.                     if(returnVal[1] = -1) and not (pIsRetry)    # Not initialized, and haven't retried already
  125.                     begin
  126.                         global gOnTargetInitFlag := undefined;
  127.                         returnVal := _OnTarget(pServiceOrTask, pParamList, pOnTarget, 1);
  128.                     end;
  129.                 end;
  130.                 else if(pServiceOrTask = 'Quit')        # Reset the global gOnTargetInitFlag when we quit
  131.                     global gOnTargetInitFlag := undefined;
  132.             
  133.             end;
  134.             catch theErr
  135.             begin
  136.                 if(theErr = -1220) and not (pIsRetry)
  137.                 begin
  138.                     global gOnTargetInitFlag := undefined;
  139.                     returnVal := _OnTarget(pServiceOrTask, pParamList, pOnTarget, 1);
  140.                 end;
  141.                 else
  142.                     exceptionDispatcher(theErr);
  143.             end;
  144.         end;
  145.         else if(ParamType = 'task')
  146.         begin
  147.             NumParams := Card(pParamList);
  148.             switch NumParams 
  149.             begin
  150.                 case 0:                    # 0 parameters
  151.                     returnVal := call (pServiceOrTask); 
  152.                 case 1:                    # 1 parameter
  153.                     returnVal := call (pServiceOrTask, pParamList[1]); 
  154.                 case 2:                    # 2 parameters
  155.                     returnVal := call (pServiceOrTask, pParamList[1], pParamList[2]); 
  156.                 case 3:                    # 3 parameters
  157.                     returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3]); 
  158.                 case 4:                    # 4 parameters
  159.                     returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4]); 
  160.                 case 5:                    # 5 parameters
  161.                     returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5]); 
  162.                 case 6:                    # 6 parameters
  163.                     returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5], pParamList[6]); 
  164.                 default:                # error
  165.                     println "Error - unsupported number of parameters - {NumParams}";
  166.             end;
  167.         end;
  168.         
  169.         if(pOnTarget)            # To cause target errors to throw if Xtools are called
  170.             match[mouse];
  171.             
  172.         return(returnVal);
  173.     end;
  174.     Catch theError
  175.         ExceptionDispatcher(theError);
  176. end;
  177.  
  178.  
  179. #########################################################################
  180. #                     OnTargetInit()
  181. #========================================================================
  182. #
  183. # Author:        GS
  184. #
  185. # Description:    Initializes OnTarget
  186. # Parameters:    None
  187. # Returns:        1 - if OnTarget launched and initialized
  188. #                0 - if OnTarget could not launch
  189. #
  190. # Examples:        OnTargetInit()  
  191. #
  192. #========================================================================
  193. # History:
  194. # KTA 7/14/93    Changed error handling
  195. #########################################################################
  196. TASK OnTargetInit()
  197. begin
  198.     returnVal := 0;
  199.     IsError := _OnTarget('Initialize',{1});
  200.     if(IsError[1])        # Some Error
  201.     begin
  202.         errorString := IsError[3];
  203.         println "Ontarget initialization failed: ", errorString;
  204.     end;
  205.     else
  206.         returnVal := 1;
  207.  
  208.     return (returnVal);
  209. end;
  210.  
  211.